import React, {Component} from 'react';
import Markdown from 'react-markdown';
import {Anchor, Row, Col} from 'antd';

const {Link} = Anchor;

class JsPage extends Component {
    constructor(props) {
        super(props);
    }

    render() {

        return (
            <div style={{background:"#c0d2bc"}}>
                <Row>
                    <Col span={19}>





                        <h3 id="byte2obj"> 对象与Byte数组相互转化 </h3>
                        <Markdown source={
                        "    //对象转byte\n" +
                        "    private byte[] ObjectToByte(Object obj) {  \n" +
                        "        byte[] bytes = null;  \n" +
                        "        try {  \n" +
                        "            // object to bytearray  \n" +
                        "            ByteArrayOutputStream bo = new ByteArrayOutputStream();  \n" +
                        "            ObjectOutputStream oo = new ObjectOutputStream(bo);  \n" +
                        "            oo.writeObject(obj);  \n" +
                        "      \n" +
                        "            bytes = bo.toByteArray();  \n" +
                        "      \n" +
                        "            bo.close();  \n" +
                        "            oo.close();  \n" +
                        "        } catch (Exception e) {  \n" +
                        "            System.out.println(\"translation\" + e.getMessage());  \n" +
                        "            e.printStackTrace();  \n" +
                        "        }  \n" +
                        "        return bytes;  \n" +
                        "    } \n" +
                        "    \n" +
                        "    //byte转对象\n" +
                        "    private Object ByteToObject(byte[] bytes) {\n" +
                        "        Object obj = null;\n" +
                        "        try {\n" +
                        "            // bytearray to object\n" +
                        "            ByteArrayInputStream bi = new ByteArrayInputStream(bytes);\n" +
                        "            ObjectInputStream oi = new ObjectInputStream(bi);\n" +
                        "\n" +
                        "            obj = oi.readObject();\n" +
                        "            bi.close();\n" +
                        "            oi.close();\n" +
                        "        } catch (Exception e) {\n" +
                        "            System.out.println(\"translation\" + e.getMessage());\n" +
                        "            e.printStackTrace();\n" +
                        "        }\n" +
                        "        return obj;\n" +
                        "    }"}/>


                    </Col>
                    <Col span={5}>
                        <Anchor showInkInFixed="true" style={{background:"#ebefe0"}}>
                            <Link href="#byte2obj" title="对象与Byte数组相互转化"/>


                        </Anchor>
                    </Col>
                </Row>
            </div>

        );
    }
}

export default JsPage;